﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using DLLPC;
using System.IO.Ports;
using DLLPC.PCAP;
using DLLPC.Utilities;
using EquipSecs300;

namespace VisionCore
{
    public static class Kernel
    {
        public static int PW = 0;
        public static OPInfo OP = new OPInfo();

        public static string CPUSerialNumber = "";
        public static GetSerialNumber serialNumber = new GetSerialNumber();

        public static bool isInitEnd = false;

        public static MotionHelper motion = new MotionHelper();
        public static ExcHelper Exc = new ExcHelper();
        //public static EfemHelper Efem = new EfemHelper();
        public static EQHelper EQ = new EQHelper();

        public static SecsEquipHelper SecsEquip;
        public static  CodeReaderHelper codeRead1=new CodeReaderHelper(ParameterHelper.SysParam.COM.CodeReader1_IP,1000);
        public static CodeReaderHelper codeRead2 = new CodeReaderHelper(ParameterHelper.SysParam.COM.CodeReader2_IP,1000);


        public static FASTUS.LaserDispHelper LaserDis;
        public static MeasureSensorComHelper MsSensor;
        public static PressureSensorComHelper PresureSensor;
        public static bool EfemPass = false;

        public static LaserInterferometer LaserOffset_InspX;
        public static LaserInterferometer LaserOffset_InspY;

        public static MarkLocate MarkLocate_ULDST = new MarkLocate();

        public static void KernelInitialization()
        {
            ParameterHelper.InitalSetting();

            ProcessHelper.CPUIDOffset = System.Environment.ProcessorCount - 8;
            ProcessHelper.Start(8);

            LogHelper.Start();

            motion.Start();
            codeRead1.Start();
            codeRead2.Start();

            //LaserDis = new FASTUS.LaserDispHelper(ParameterHelper.SysParam.COM.LaserDisp_IP);
            //LaserDis.Start();
            //MsSensor = new MeasureSensorComHelper(ParameterHelper.SysParam.COM.MsSensorPort.ToString(), 38400, 8,Parity.None, StopBits.Two);
            //MsSensor.Start();

            //PresureSensor = new PressureSensorComHelper(ParameterHelper.SysParam.COM.PresureSensorPort.ToString(), 9600, 8, Parity.None, StopBits.One);
            //PresureSensor.Start();


            //RTCHelper.Start();

            EQ.Start();
            Exc.Start();
            PulseOn.Start();
        }

        public static void Quit()
        {
            ProcessHelper.Quit();

            motion.Quit();

            //LaserDis.Quit();
            //MsSensor.Quit();
            //PresureSensor.Quit();

            //RTCHelper.Quit();

            EQ.Quit();
            Exc.Quit();
            //Efem.Quit();
            PulseOn.Quit();
            LogHelper.Quit();
        }
    }
}
